﻿using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Text;

using BlueCMS.Core.Data.Query.Clauses;

namespace BlueCMS.Core.Data.Query
{
    public class InsertQuery 
    {
        InsertClause InsertClause { get; set; }
        ValuesClause ValuesClause { get; set; }
        SelectQuery Query { get; set; }

        public Dictionary<string, DbParameter> Parameters { get; private set; }

        public InsertQuery()
        {
            InsertClause = new InsertClause();
            ValuesClause = new ValuesClause();
            Parameters = new Dictionary<string, DbParameter>();
        }

        public IInsertClause Insert
        {
            get { return InsertClause; }
        }

        public IValuesClause Values
        {
            get { return ValuesClause; }
        }

        public SelectQuery Select
        {
            get { return Query; }
        }

        public string Sql
        {
            get
            {
                return DataAccess.Instance.GetQueryGenerator().ProcessInsertQuery(InsertClause, ValuesClause, Query, Parameters);
            }
        }

        public override string ToString()
        {
            return Sql;
        }
    }
}
